package week03;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.Arrays;

public class T022 {
//	public static void main(String[] args) throws IOException {
//		BufferedReader br =new BufferedReader(new FileReader(new File("D:\\桌面\\蓝桥杯\\第三周\\p022-names.txt")));
//		String line ="";
//		String str ="";
//		while((line=br.readLine())!=null) {
//			line=line.replace("\"", "");//去掉双引号
//			str+=line;
//		}
//		String[] names = str.split(",");
//		Arrays.sort(names);
//		int len1=names.length;
//		long sum=0;
//		long[]a=new long [len1];
//		for(int i=0;i<len1;i++) {
//			int len=names[i].length();
//			for(int j=0;j<len;j++) {
//				a[i]+=(names[i].charAt(j)-'A'+1);
//			}
//			a[i]*=(i+1);
//			sum+=a[i];
//		}
//		System.out.println(sum);
//	}
	
	public static void main(String[] args) throws IOException {
		File file = new File("D:\\桌面\\蓝桥杯\\第三周\\p022-names.txt");
		FileReader fileReader = new FileReader(file);
		BufferedReader br = new BufferedReader(fileReader);
		String line = "";
		String str = "";
		while((line=br.readLine())!=null) {
			line =line.replace("\"", "");
			str+=line;
		}
		String[] names = str.split(",");
		Arrays.sort(names);
		int len1 = names.length;
		long sum=0;
		long[]a = new long[len1+1];
		for(int i=0;i<len1;i++) {
			int len = names[i].length();
			for(int j=0;j<len;j++) {
				a[i]+=(names[i].charAt(j)-'A'+1);
			}
			a[i]*=(i+1);
			sum+=a[i];
		}
		System.out.println(sum);
	}
}
